﻿@{
    string content = ViewBag.Content;
}
<div class="widget-content">
    <div class="widget-box">
        <div class="widget-title">
            <span class="icon"><i class="icon-align-justify"></i></span>
            <h5>
                编辑模版内容</h5>
        </div>
        <div class="widget-content nopadding">
            <div class="alert alert-success" style="display: none">
                <a class="close" data-dismiss="alert" href="#">×</a>
                <h4 class="alert-heading">
                    保存成功!</h4>
                您的修改已保存成功.
            </div>
            <div class="alert alert-error" style="display: none">
                <a class="close" data-dismiss="alert" href="#">×</a>
                <h4 class="alert-heading">
                    保存失败!</h4>
                保存失败或出错，请稍后重试.
            </div>
            <form action="@Url.Action("Save")" method="post" class="form-horizontal">
            <div class="control-group">
                <label class="control-label">
                    内容:</label>
                <div class="controls">
                    <div class="span6">
                        @Html.TextArea("Content", content, new { rows = "25"  })
                        <span class="help-block">请小心修改模版内容!!</span>
                    </div>
                </div>
            </div>
            <div class="form-actions"> <button id="BtnSave" type="button" class="btn btn-success"
            tid="@ViewBag.Id"> 保存</button> <a href="@Url.Action("Index")" class="btn btn-danger">返回列表</a>
            </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function () {

        $("#BtnSave").click(function () {
            $("#LoadingBox").show();
            $(this).hide();
            $.post('@Url.Action("Save")', { "id": $(this).attr("tid"), "content": escape($("#Content").val()) }, function (result) {
                result === "Ok" ? $(".alert-success").show() : $(".alert-error").show();
                $(window).scrollTop(0);
                $("#LoadingBox").hide();
                $("#BtnSave").show();
            });
        });
    });
</script>
